package sfeir.ergosum.tools;

import java.util.ArrayList;

import sfeir.ergosum.HiveActivity;

import android.content.Context;
import android.content.SharedPreferences;

public class ThemeColor {

    private Context mContext;
    private SharedPreferences mPrefs;
    private String prefTheme;
    private ArrayList<Integer> cellColors;
    private ArrayList<Integer> menuColors;

    public ThemeColor(Context context) {
        mContext=context;
        mPrefs = mContext.getSharedPreferences(HiveActivity.PREFS_NAME, Context.MODE_WORLD_READABLE);

        prefTheme = mPrefs.getString("preference_theme", "HiveGotContacts");

        cellColors = new ArrayList<Integer>();
        menuColors = new ArrayList<Integer>();

        if (prefTheme.equals("HiveGotContacts")) {
            cellColors.add(0xFFC52966);
            cellColors.add(0xFF99BA13);
            cellColors.add(0xFFC61503);
            menuColors.add(0xFFE7A825);//items
            menuColors.add(0xFF2F7C1E);//backer
        } else if (prefTheme.equals("blue")) {
            cellColors.add(0xFF2677AC);
            cellColors.add(0xFF118DDB);
            cellColors.add(0xFF5000FF);
            menuColors.add(0xFF00BFFF);//items
            menuColors.add(0xFF5C3A99);//backer
        } else if (prefTheme.equals("green")) {
            cellColors.add(0xFF006D00);
            cellColors.add(0xFF00DC00);
            cellColors.add(0xFF00CC59);
            menuColors.add(0xFFAFD35B);//items
            menuColors.add(0xFF47BC8F);//backer
        } else if (prefTheme.equals("pastel")) {
            cellColors.add(0xFF9EFFC6);
            cellColors.add(0xFFD6FFA5);
            cellColors.add(0xFFFFB5C8);
            menuColors.add(0xFFCCCEFF);//items
            menuColors.add(0xFFE5E540);//backer
        } else if (prefTheme.equals("sepia")) {
            cellColors.add(0xFF988675);
            cellColors.add(0xFFE5DFD9);
            cellColors.add(0xFFBBAEA1);
            menuColors.add(0xFFA57742);//items
            menuColors.add(0xFF5B4906);//backer
        } else if (prefTheme.equals("customized")){
            setCustomised();
        } else {
            cellColors.add(0xFFC52966);
            cellColors.add(0xFF99BA13);
            cellColors.add(0xFFC61503);
            menuColors.add(0xFFE7A825);//items
            menuColors.add(0xFF2F7C1E);//backer
        }
    }

    public ArrayList<Integer> getMenuColors() {
        return menuColors;
    }

    public ArrayList<Integer> getCellColors() {
        return cellColors;
    }

    private void setCustomised() {
        cellColors.add(mPrefs.getInt("color1", 0xFFC52966));
        cellColors.add(mPrefs.getInt("color2", 0xFF99BA13));
        cellColors.add(mPrefs.getInt("color3", 0xFFC61503));
        menuColors.add(mPrefs.getInt("color4", 0xFFE7A825));
        menuColors.add(mPrefs.getInt("color5", 0xFF2F7C1E));
    }
}
